import request from '@/utils/request.js';

export function login(data) {
  return request({
    url: '/login/doLogin',
    method: 'post',
    data
  })
}

export function getInfo(userId, username) {
  return request({
    url: '/users',
    method: 'get',
    params: { id:userId, userName:username }
  })
}

export function logout(username) {
  return request({
    url: '/login/logout',
    method: 'get',
    params:{
      userName:username
    }
  })
}

//用户列表

//分页获取所有的系统用户信息
export function reqUserList (page, size) {
  return request ({
    url:"/users/pages",
    method:"get",
    params:{
      page,
      size
    }
  })
}
//创建新用户
export function reqCreateUser (data) {
  return request ({
    url:"/users",
    method:"post",
    data:data
  })
}
//更新用户
export function reqUpdateUser (data) {
  return request({
    url:"/users",
    method:"put",
    data:data
  })
}
//删除用户
export function reqDeleteUser (userId) {
  return request({
    url:"/users/" + userId,
    method:"delete"
  })
}
//用户密码重置
export function reqUpdateUserPassword (data) {
  return request({
    url:"/users/reset",
    method:"post",
    data:data
  })
}
//用户名模糊查询用户列表信息
export function reqUserListByUserName (page,size,username){
  return request({
    url:"/users/pages",
    method:"get",
    params:{
      page,
      size,
      userName:username
    }
  })
}
//下载导入用户模板
export function reqDownloadUserImportTemplate () {
  return request({
    url:"/downloads/excelTemplate",
    method:"get",
    responseType:"blob"
  })
}
//导入excel用户信息
export function reqUploadUserInfoExcel (formData) {
  return request({
    url:"/users/usersImportExcel",
    method:"post",
    data:formData
  })
}



//用户角色相关api

//分页查询角色列表
export function reqRoleList (page, size) {
  return request({
    url:"/roles/pages",
    method:"get",
    params:{
      page,
      size
    }
  })
}
//创建角色
export function reqCreateRole (params) {
  return request ({
    url:"/roles",
    method:"post",
    data:{
      roleName:params.roleName,
      roleDes:params.roleDesc,
      menuIds:params.permissionIds
    }
  })
}
//更新角色
export function reqUpdateRole (params) {
  return request ({
    url:"/roles",
    method:"put",
    data:{
      id:params.id,
      roleName:params.roleName,
      roleDes:params.roleDesc,
      menuIds:params.permissionIds
    }
  })
}
//删除角色
export function reqDelRole (roleId) {
  return request({
    url:"/roles/" + roleId,
    method:"delete"
  })
}


//查询个人工作台备货单完成情况
export function reqOrderQuantityInfo(){
  return request({
    url:"/productionOrderDetails/stock/order/quantity",
    method:"get"
  })
}


//查询近七天工时完成情况
export function reqWorkTimeInfo () {
  return request({
    url:"/checkRecords/work/time",
    method:"get"
  })
}